#include "Tray.h"

Tray::Tray()
{
	menu = gtk_menu_new();
	menuItemView = gtk_menu_item_new_with_label ("View");
    menuItemExit = gtk_menu_item_new_with_label ("Exit");

	gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuItemView);
    gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuItemExit);
    gtk_widget_show_all (menu);
	//g_signal_connect (G_OBJECT (menuItemView), "activate", G_CALLBACK (trayView), window);
    //g_signal_connect (G_OBJECT (menuItemExit), "activate", G_CALLBACK (trayExit), NULL);
	trayIcon  = gtk_status_icon_new_from_file ("icon.png");
	gtk_status_icon_set_tooltip (trayIcon, "MsgWatcherGTK");
    //connect handlers for mouse events
    //g_signal_connect(GTK_STATUS_ICON (trayIcon), "activate", GTK_SIGNAL_FUNC (trayIconActivated), window);
    //g_signal_connect(GTK_STATUS_ICON (trayIcon), "popup-menu", GTK_SIGNAL_FUNC (trayIconPopup), menu);
    gtk_status_icon_set_visible(trayIcon, TRUE); //set icon initially invisible
    
    
    GtkWidget *menuBar, *menuItemTopLvl, *mainMenu, *mainMenuItemExit;
    menuBar = gtk_menu_bar_new ();
    menuItemTopLvl = gtk_menu_item_new_with_label ("Menu");
    gtk_menu_shell_append (GTK_MENU_SHELL (menuBar), menuItemTopLvl);
    
    mainMenu = gtk_menu_new ();
    gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuItemTopLvl), mainMenu);
    mainMenuItemExit = gtk_menu_item_new_with_label ("Quit");
    g_signal_connect (G_OBJECT (mainMenuItemExit), "activate", G_CALLBACK (trayExit), NULL);
    gtk_menu_shell_append (GTK_MENU_SHELL (mainMenu), mainMenuItemExit);
    
    //g_signal_connect (G_OBJECT (window), "destroy", G_CALLBACK (destroy), NULL);
    //g_signal_connect (G_OBJECT (window), "delete_event", G_CALLBACK (delete_event), trayIcon);
    //g_signal_connect (G_OBJECT (window), "window-state-event", G_CALLBACK (window_state_event), trayIcon);
    //gtk_container_add (GTK_CONTAINER (window), menuBar);
//    gtk_widget_show_all (window);
}

Tray::~Tray()
{}